//
//  WYJAppleTableViewCell.m
//  QuickCure
//
//  Created by believewilliam on 16/9/12.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "WYJAppleTableViewCell.h"
#import <Masonry.h>

@interface WYJAppleTableViewCell ()
@property (nonatomic, strong) UILabel *lab_name;
@property (nonatomic, strong) UILabel *lab_disease;
@property (nonatomic, strong) UILabel *lab_time;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UILabel *lab_doctor;
@property (nonatomic, strong) UILabel *lab_rank;
@property (nonatomic, strong) UILabel *lab_hospital;
@end


@implementation WYJAppleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.lab_name = [[UILabel alloc] init];
        self.lab_disease = [[UILabel alloc] init];
        self.lab_time = [[UILabel alloc] init];
        self.line = [[UIView alloc] init];
        self.line.backgroundColor = [UIColor blackColor];
        self.btn_status = [[UIButton alloc] init];
        self.btn_status.backgroundColor = kThemeColor;
        self.lab_doctor = [[UILabel alloc] init];
        self.lab_rank = [[UILabel alloc] init];
        self.lab_hospital = [[UILabel alloc] init];
        // 字体适配不同尺寸屏幕
        if (kDevice_Is_iPhone5) {
            self.lab_name.font = [UIFont systemFontOfSize:12];
            self.lab_disease.font = [UIFont systemFontOfSize:12];
            self.lab_time.font = [UIFont systemFontOfSize:12];
            self.lab_doctor.font = [UIFont systemFontOfSize:12];
            self.lab_rank.font = [UIFont systemFontOfSize:12];
            self.lab_hospital.font = [UIFont systemFontOfSize:12];

        }else if (kDevice_Is_iPhone6) {
            self.lab_name.font = [UIFont systemFontOfSize:14];
            self.lab_disease.font = [UIFont systemFontOfSize:14];
            self.lab_time.font = [UIFont systemFontOfSize:14];
            self.lab_doctor.font = [UIFont systemFontOfSize:14];
            self.lab_rank.font = [UIFont systemFontOfSize:14];
            self.lab_hospital.font = [UIFont systemFontOfSize:14];

        }
        
        [self.contentView addSubview:self.lab_name];
        [self.contentView addSubview:self.lab_disease];
        [self.contentView addSubview:self.lab_time];
        [self.contentView addSubview:self.line];
        [self.contentView addSubview:self.btn_status];
        [self.contentView addSubview:self.lab_doctor];
        [self.contentView addSubview:self.lab_rank];
        [self.contentView addSubview:self.lab_hospital];
    }
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    // 布局子控件
    [self.lab_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.line.mas_top).offset(-5);
        make.left.equalTo(self.contentView).offset(10);
        
    }];
    
    [self.lab_disease mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.line.mas_top).offset(-5);
        make.left.equalTo(self.lab_name.mas_right).offset(10);
    }];
    
    [self.lab_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.line.mas_top).offset(-5);
        make.left.equalTo(self.lab_disease.mas_right).offset(7);
    }];
    

    [self.btn_status mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.right.equalTo(self.contentView).offset(0);
        make.width.equalTo(self.frame.size.height - 20);
        make.bottom.equalTo(self.contentView).offset(-10);
        
    }];
    self.btn_status.layer.cornerRadius = 32.5;
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(self.frame.size.height / 2);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.btn_status.mas_left).offset(0);
        make.height.mas_equalTo(1);
    }];
    
    [self.lab_doctor mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line.mas_bottom).offset(5);
        make.left.equalTo(self.contentView).offset(10);
    }];
    
    [self.lab_rank mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line.mas_bottom).offset(5);
        make.left.equalTo(self.lab_doctor.mas_right).offset(10);
    }];
    
    [self.lab_hospital mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line.mas_bottom).offset(5);
        make.left.equalTo(self.lab_rank.mas_right).offset(20);
    }];
    
    
    
}
// 给cell中自定义控件设置内容
- (void)setModel:(WYJApplyModel *)model {

    
    _model = model;
    self.lab_name.text = model.name;
    self.lab_disease.text = model.disease;
    self.lab_time.text = model.time;
    [self.btn_status setTitle:model.status forState:UIControlStateNormal];
    [self.btn_status setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.lab_doctor.text = model.doctor;
    self.lab_rank.text = model.rank;
    self.lab_hospital.text = model.hospital;
    
}

@end
